<!--管理员用户所有的企业信息-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="layui/css/layui.css" media="all">
    <title>Title</title>
</head>
<body>
<div class='layui-fiuld'>
    <div class='layui-row'>
        <div class='layui-col-md10 '>

            <table class='layui-table' id="enters" lay-filter="ad_enters"></table>
        </div>
    </div>
</div>
</body>
<script src="layui/layui.js" type='text/javascript'></script>
<script type="text/html" id='barDemo'>
    <a class="layui-btn layui-btn-xs" lay-event="showImg">查看大图</a>
<!--    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>-->
</script>

<script type="text/html" id="stateSwitch">
    <input type="checkbox" name="state"  value={{d.state}}
           lay-skin="switch" lay-text="可用|锁定" mid={{d.enterpriseId}}
           lay-filter="stateCheck" {{ d.state == 0 ? '' : 'checked' }}/>
</script>

<script>
    layui.use(['table','form','layer'],function (){
        var table=layui.table;
        var form=layui.form;
        var layer=layui.layer;
        var $=layer.$;
        table.render({
            id:"Adenter",
            elem:'#enters',
            method:'POST',
            title:"企业信息审核",
            url:'/enter/viewEnters',
            page:false,
            totalRow:true,
            skin:'nob',
            even:true,
            cellMinWidth: 80,
            toolbar:true,
            response:{
                statusName:"code",
                statusCode:200

            },
            parseData:function(res){//信息的整合
                return{
                    "code":res.code,
                    "msg":res.msg,
                    "count":res.data.enterprises.size,
                    "data":res.data.enterprises
                };
            },

            defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                title: '提示'
                ,layEvent: 'LAYTABLE_TIPS'
                ,icon: 'layui-icon-tips'
            }],
            cols:[[
                {fixed:'left',type:'checkbox'},
                {field:'number',title:'用户名',width:100},
                {field: 'enterpriseId',title:'企业代码',width:100},
                {field:'ename',title:'企业名',width:100},
                {field:'capital',title:'注册资本',width:100},
                {field:'license',title:'营业执照',align:'center',width:100,
                    templet:function (d){return "<img class='dialog' src='"+d.license+"'style='height:100px;'/>"}
                },
                {field:"province",title:"所在省",width:100},
                {field:"area",title:"所在市",width:100},
                {field:"type",title:"企业性质",width:100},
                {field:"organize",title:"企业类型",width:100},
                {field:"state",title:"状态", width:85,
                templet: '#stateSwitch', unresize: true},
                {fixed: 'right',title:"操作",width:100, align:'center', toolbar: '#barDemo'}

            ]],
            done:function(res,curr,count){
                exportData=res.data;//获取数据表格的中的数据
            }
        });
        table.on('tool(ad_enters)',function (obj){
            var data=obj.data;
            if(obj.event=='showImg'){
                var $=layui.$;
                var img_src = $('.dialog').attr('src');//依赖jquery的解释
                var img = "<img src='" + img_src + "'/>";
                layer.open({
                    type: 1,
                    title: '营业执照',
                    maxmin: true,
                    anim: 4,
                    content: img
                });


            }

        });
        form.on('switch(stateCheck)',function (obj){
            var $=layui.$;
            //获取属性绑定的id值
            var enterpriseId=$(this).attr('mid');
            var state=obj.elem.checked?1:0;
            var data=new Object();
            data.enterpriseId=enterpriseId;
            data.state=state;
            $.ajax({
                url:"/enter/auditInfo",
                type:'post',
                dataType:'json',
                data:data,
                success:function (ret){
                    if(ret.code===200){
                        layer.msg('状态更新成功');
                    }
                    else{
                        layer.msg("状态更新失败");
                    }
                },
                error:function (ret){
                    layer.msg('出现错误');
                }




            });
            form.render('checkbox')


        });

    });
</script>
</html>